﻿@model IEnumerable<Hospital.ViewModel.SpecialistViewModel>

@{
    ViewBag.Title = "Default";
}

<h2>专家列表</h2>

@using (Html.BeginForm())
{
    <label>姓名：</label>
    <input type="text" name="Name" />
    <label>科室类别：</label>
    <input type="text" name="Category" />
    <label>科室：</label>
    <input type="text" name="Department" />
    <input type="submit" value="查询" class="btn btn-default" />
    <a class="btn btn-default" href="@Url.Action("Add", "Home")">添加</a>
}
<table class="table">
    <tr>
        <th>

        </th>
        <th>
            姓名
        </th>
        <th>
            性别
        </th>
        <th>
            科室类别
        </th>
        <th>
            科室
        </th>
        <th>
            职务名称
        </th>
        <th>
            添加时间
        </th>
        <th>
            操作
        </th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.ID)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @(item.Sex==1?"男":"女")
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Category)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Department)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.TitleName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.GetDateTime)
            </td>
            <td>
                <a class="btn btn-warning" href="@Url.Action("Edit","Home", new { id = item.ID })">修改</a>
                <a class="btn btn-danger" href="javascript:;" onclick="Delete(@item.ID)">删除</a>
            </td>
        </tr>
    }

</table>
<script>
    function Delete(id) {
        if (confirm("你确定要删除吗?")) {
            $.post(
                "@Url.Action("Delete", "Home")", { id: id }, function (data) {
                    if (data.State == 1) {
                        alert(data.Message);
                        location.reload();
                    } else {
                        alert(data.Message);
                    }
                }
            );
        }
    }
</script>